﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
      //  public Form1()
      //  {
           
     //   }
        private int Id;
        private string name;
        private int Age;
        private int Score;
        public Form1(int Id, string Name, int Age, int Score)
        { 
            InitializeComponent();
            this.Id = Id;
            this.name = Name;
            this.Age = Age;
            this.Score = Score;


        }
        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: 这行代码将数据加载到表“schoolsDataSet.Students”中。您可以根据需要移动或删除它。
           
            var a = "select * from Users";
            var dt = dbHelper.GetDataTable(a);

            dataGridView1.DataSource = dt;

            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dataGridView1.ReadOnly = true;
            dataGridView1.AllowUserToAddRows = false;

        }
//修改
        private void button4_Click(object sender, EventArgs e)
        {
            var Id = (int)dataGridView1.SelectedRows[0].Cells["Id"].Value;
            var Name = (string)dataGridView1.SelectedRows[0].Cells["Name"].Value;
            var Age= (int)dataGridView1.SelectedRows[0].Cells["Age"].Value;
            var Sorce = (int)dataGridView1.SelectedRows[0].Cells["Sorce"].Value;

            edirform form = new edirform();
            form.Show();
        }
        //搜索
        private void button1_Click(object sender, EventArgs e)
        {
            var name = textBox1.Text;
            var sql = string.Format("select *from Students where Name like '%{0}%',name");
            var dt = dbHelper.GetDataTable(sql);
            dataGridView1.DataSource = dt;
        }
        //增加
        private void button2_Click(object sender, EventArgs e)
        {
            edirform form = new edirform();
            form.Show();
        }
        //删除
        private void button3_Click(object sender, EventArgs e)
        {

        }
    }
}
